package cn.wizzer.app.user.modules.models;


import cn.wizzer.app.sys.modules.models.SysCollectBank;
import cn.wizzer.app.user.modules.models.enums.ChannelEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Table("user_recharge")
@TableIndexes({@Index(name = "unique_no", fields = {"no"}, unique = true),
        @Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false)})
public class UserRecharge extends BaseModel implements Serializable {

    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column("no")
    @Comment("编号")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String no;

    @Column("user_id")
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    @Comment("付款人姓名")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 16)
    private String payer;

    @Column("remark")
    @Comment("备注")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String remark;

    @Column
    @Comment("充值金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal amount;
    /**
     * 待到账状态需要可以做入账（已到账）处理，以及不入账（支付异常（失败））处理
     */
    @Column
    @Comment("状态->-1:取消0:待确认1:待到账2:成功3:失败")
    @ColDefine(type = ColType.INT, width = 1)
    private Integer status;

    @Column
    @Comment("充值通道->手动/支付宝/微信/银联")
    @ColDefine(type = ColType.VARCHAR, width = 12)
    private ChannelEnum channel;

    @Column("bank_id")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String bankId;

    @Column("sign")
    @ColDefine(type = ColType.VARCHAR, width = 4)
    private String sign;

    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    //Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
    private Long ctAt;

    private SysCollectBank collectBank;


}
